package com.sqlloader.views;
import com.sqlloader.SqlLoaderImageRegistry;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import com.sqlloader.views.actions.OpenFileAction;
import com.sqlloader.views.actions.OutputControlFileAction;
import com.sqlloader.views.widgets.DataTableViewer;
import com.sqlloader.views.widgets.DataText;
public class LoadDataView extends ViewPart {

	public static String ID="com.sqlloader.views.LoadDataView";
	private DataText dataText;
	private OpenFileAction openFileAction;
	private OutputControlFileAction outputControlFileAction;
	DataTableViewer tableViewer ;
	private String dataFilename;
	public String getDataFilename() {
		return dataFilename;
	}

	public void setDataFilename(String dataFilename) {
		this.dataFilename = dataFilename;
	}

	public DataTableViewer getTableViewer() {
		return tableViewer;
	}

	public void setTableViewer(DataTableViewer tableViewer) {
		this.tableViewer = tableViewer;
	}

	public void createPartControl(Composite parent) {
		// TODO Auto-generated method stub
		createActions();
		initializeToolBar();
		initializeMenu();
		SashForm sash_form = new SashForm(parent, SWT.VERTICAL | SWT.NULL);
		dataText=new DataText(sash_form,SWT.BORDER|SWT.MULTI);
		tableViewer = new DataTableViewer(sash_form, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER|SWT.V_SCROLL|SWT.H_SCROLL);
		sash_form.setWeights(new int[]{1,1});
	}

	public void setFocus() {
		// TODO Auto-generated method stub
		
	}
	
	private void createActions()
	{
		openFileAction=new OpenFileAction(SqlLoaderImageRegistry.OPEN_ICON,SqlLoaderImageRegistry.getImageRegistry().getDescriptor(SqlLoaderImageRegistry.OPEN_ICON),this);
		outputControlFileAction=new OutputControlFileAction(SqlLoaderImageRegistry.OUTPUT_ICON,SqlLoaderImageRegistry.getImageRegistry().getDescriptor(SqlLoaderImageRegistry.OUTPUT_ICON),this);
	}
	
	private void initializeToolBar() {
		 IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
		 
		 toolbarManager.add(openFileAction);
		 toolbarManager.add(outputControlFileAction);
	}
	private void initializeMenu() {
		 IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
	}
	public DataText getDataText() {
		return dataText;
	}

}
